<template>
  <div class="footCont">
    <div
      @click="footfn(item)"
      :class="$route.path == item.url ? 'footItem_active' : 'footItem'"
      :key="index"
      v-for="(item, index) in footArr"
    >
      <div v-if="!item.showMask">
        <div :class="'iconfont ' + item.icon"></div>
        <div class="footVal">{{ item.val }}</div>
      </div>
      <div v-if="item.msg && showMsgCount > 0" class="msgIcon"></div>
      <div v-if="item.showMask" class="footMask">
        <div class="sendBtn">
          <img src="/img/addImg.png" />
        </div>
      </div>
    </div>
    <van-popup v-model:show="showSendMask" round position="bottom">
      <div class="sendMask">
        <div class="sendHead">请选择发布类型</div>
        <div class="sendCont">
          <div class="sendItem" @click="developFn">
            <div class="sendItemName">外包项目</div>
            <div class="sendDes">
              <div>远程｜驻场</div>
              <div>发布外包项目需求</div>
            </div>
            <img src="/img/sendDevelop.png" />
          </div>
          <div class="sendItem greenBack" @click="sendUserFn">
            <div class="sendItemName">岗位招聘</div>
            <div class="sendDes">
              <div>招贤纳士</div>
              <div>发布全职岗位招聘</div>
            </div>
            <img src="/img/sendUser.png" />
          </div>
        </div>
        <div class="sendTip">没有找到合适的方案?联系客服1对1服务。</div>
        <div class="sendTip">客服微信：whasd666</div>
      </div>
    </van-popup>
  </div>
</template>

<script>
import { getMessageCount } from "@/http/api";
export default {
  components: {},
  data() {
    return {
      showSendMask: false,
      showMsgCount: 0,
      footArr: [
        {
          url: "/home",
          val: "大厅",
          icon: "icon-wangzhantubiaoji2_huaban1fuben24",
          active: false,
          showMask: false,
        },
        {
          url: "/order",
          val: "记录",
          icon: "icon-dingdanjilu2",
          active: false,
          showMask: false,
        },
        {
          url: "/send",
          val: "发布需求",
          icon: "",
          active: false,
          showMask: true,
        },
        {
          url: "/msg",
          val: "消息",
          icon: "icon-xiaoxi3",
          active: true,
          showMask: false,
          msg: true,
        },
        {
          url: "/user",
          val: "我的",
          icon: "icon-xiaolian",
          active: true,
          showMask: false,
        },
      ],
    };
  },
  props: {},
  methods: {
    footfn(item) {
      if (item.showMask) {
        this.showSendMask = true;
      } else {
        this.$router.replace({ path: item.url });
      }
    },
    developFn() {
      this.$router.replace({ path: "/send" });
    },
    sendUserFn() {
      this.$router.replace({ path: "/sendWork" });
    },
    getMsg() {
      getMessageCount().then((res) => {
        if (res.data.code == 1) {
          this.showMsgCount = res.data.data;
        }
      });
    },
  },
  mounted() {},
  created() {
    this.getMsg();
  },
};
</script>

<style scoped lang="less">
.footCont {
  width: 100%;
  padding: 0.25rem 0;
  box-sizing: border-box;
  position: fixed;
  left: 0;
  z-index: 102;
  bottom: -1px;
  background-color: #fff;
  // border-top: 1px solid #ebebeb;
  // box-shadow: 0 -0.1rem 0.5rem #ebebeb;
  display: flex;
  justify-content: space-between;
  .footItem,
  .footItem_active {
    width: 50%;
    height: 3rem;
    display: flex;
    align-items: center;
    flex-direction: column;
    color: #999;
    justify-content: center;
    position: relative;
    .msgIcon {
      font-size: 0.6rem;
      position: absolute;
      right: 1.15rem;
      top: 0.25rem;
      padding: 0.2rem;
      box-sizing: border-box;
      background-color: #ff5757;
      color: #fff;
      border-radius: 2rem;
    }
    img {
      width: 1.5rem;
    }
    .iconfont {
      font-size: 1.1rem;
    }
    .footVal {
      font-size: 0.6rem;
      text-align: center;
      margin-top: 0.1rem;
    }
    .footMask {
      width: 4rem;
      height: 3rem;
      box-sizing: border-box;
      display: flex;
      justify-content: center;
      .sendBtn {
        background-color: #fff;
        position: relative;
        border-radius: 50%;
        top: -1.2rem;
        padding: 0.2rem;
        width: 2.7rem;
        img {
          width: 100%;
        }
      }
    }
  }
  .footItem_active {
    color: #86a9fb;
  }
  .sendMask {
    width: 100%;
    padding: 0.75rem 4%;
    background-color: #fff;
    box-sizing: border-box;
    .sendHead {
      font-size: 0.8rem;
      font-weight: bold;
    }
    .sendCont {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 0.75rem;
      margin-bottom: 0.75rem;
      .sendItem {
        width: 46%;
        padding: 0.75rem 0.5rem;
        box-sizing: border-box;
        background-image: linear-gradient(to right bottom, #adc5fe, #5587fc);
        border-radius: 0.5rem;
        color: #fff;
        position: relative;
        .sendItemName {
          font-size: 0.7rem;
          font-weight: bold;
        }
        .sendDes {
          font-size: 0.6rem;
          margin-top: 0.25rem;
        }
        img {
          width: 2rem;
          right: 0.5rem;
          top: 0.5rem;
          position: absolute;
        }
      }
      .greenBack {
        background-image: linear-gradient(to right bottom, #cfb6ff, #905af5);
      }
    }
    .sendTip {
      font-size: 0.6rem;
      color: #999;
      margin-bottom: 0.25rem;
    }
  }
}
</style>
